﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jayden.Dll.ECMAScript
{
	public class Variable : Statement
	{
		private List<KeyValuePair<string, Expression>> m_Identifiers = new List<KeyValuePair<string, Expression>>();

		public Variable(string name) { m_Identifiers.Add(new KeyValuePair<string, Expression>(name, null)); }



		public void RenderStatement(int level, StringBuilder builder)
		{
			StatementList.AppendSpacing(level, "\t", builder);
			builder.Append("var ");
			for (int c = 0; c < m_Identifiers.Count; c++)
			{
				if (c > 0)
					builder.Append(", ");
				KeyValuePair<string, Expression> pair = m_Identifiers[c];
				builder.Append(pair.Key);
				if (pair.Value != null)
				{
					builder.Append(" = ");
					pair.Value.RenderExpression(builder);
				}
			}
			builder.AppendLine(";");
		}
	}
}
